<template>
	<not-login-page v-if="!userStore.userInfo"></not-login-page>
	<view v-else :class="nowTheme()">
		<common-top>
			<template #name>我</template>
		</common-top>
		<button @click="logOut()">退出</button>
		<button @click="toChangeTheme('dark')">切换暗黑主题</button>
		<button @click="toChangeTheme('light')">切换默认主题</button>
	</view>

</template>

<script setup>
import {useUserStore} from '@/stores/userStore.js'
import {logOutAPI,selfAPI} from '/services/user.js'
import { onLoad } from '@dcloudio/uni-app'
import {setTheme,nowTheme,changeTheme} from '@/utils/theme.js'
const userStore = useUserStore()

const logOut = async()=>{
	const res = await logOutAPI()
	if(res.code==200){
		uni.showToast({ icon: 'success', title: '退出成功' })
		await userStore.clearUserInfo()
		await setTheme()
	}
}

const toChangeTheme = (val)=>{
	changeTheme(val)
}

const selfInfo = async()=>{
	const res = await selfAPI()
	console.log(res)
}

onLoad(()=>{
	// console.log(userStore.userInfo.chatToken)

	// selfInfo()
})	
</script>

<style>
	       
</style>
